package com.learner.course.controller.api;

import com.learner.course.service.CourseBaseService;
import com.learner.pojo.course.CourseBase;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

/**
 * @author ice2020x
 * @date 2022-01-27 19:42
 * @description:
 */
@Slf4j
@RestController
@RequestMapping("/api/edu/course")
public class ApiCourseBaseController {


    @Autowired
    CourseBaseService courseBaseService;

    /**
     * 根据id查询课程信息
     *
     * @param courseId 课程id
     * @return 结果
     */
    @GetMapping("/course_info/get/{id}")
    public CourseBase getCourseBaseById(@PathVariable("id") String courseId){
        log.info("根据id查询课程信息，id:{}", courseId);
        return courseBaseService.getCourseBaseById(courseId);
    }

    /**
     * 查询讲师对应的课程
     *
     * @param teacherId 讲师id
     * @param pageNum   page
     * @param pageSize  pageSize
     * @return 结果
     */
    @GetMapping("/course_info/self/list/{pageNum}/{pageSize}/{id}")
    public List<CourseBase> getCourseListByTeacherId(@PathVariable("id") String teacherId, @PathVariable("pageNum") int pageNum, @PathVariable("pageSize") int pageSize) {
        log.info("查询讲师:{}对应的课程", teacherId);
        return courseBaseService.getCourseListByTeacherId(teacherId, pageNum, pageSize);
    }
}
